package net.hvacapp.cmvrfforandroid.ui.project.view;

        import android.content.Context;
        import android.util.AttributeSet;
        import android.view.LayoutInflater;
        import android.view.View;
        import android.widget.ImageView;
        import android.widget.LinearLayout;
        import android.widget.TextView;

        import com.mirror.android.common.util.StringUtils;

        import net.hvacapp.cmvrfforandroid.R;

/**
 * Created by zhangnorman on 15/8/8.
 */
public class TwoLinesCellView extends LinearLayout {

    private LinearLayout mContentLl;
    private TextView mTitleTv;
    private TextView mDescTv;
    private ImageView mSelIv;

    public TwoLinesCellView(Context context) {
        super(context);
        init(context, 0);
    }

    public TwoLinesCellView(Context context, AttributeSet attrs) {
        super(context, attrs);
        init(context, 0);
    }

    public TwoLinesCellView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
        init(context, defStyle);
    }

    public void setOnItemClickListener(View.OnClickListener onClickListener) {
        mContentLl.setOnClickListener(onClickListener);
    }

    public void setTitleString(String title) {
        mTitleTv.setText(title);
    }

    public void setDescString(String desc) {
        mDescTv.setText(desc);
    }

    public void setItemSelected(boolean selected) {
        if (selected) {
            mSelIv.setImageResource(R.drawable.user_selection_hint);
            mSelIv.setVisibility(VISIBLE);
        }
        else {
            mSelIv.setVisibility(INVISIBLE);
        }
    }

    private void init(Context context, int defStyle) {
        LayoutInflater.from(context).inflate(R.layout.two_lines_cell_item, this,
                true);
        mTitleTv = (TextView) findViewById(R.id.tv_title);
        mDescTv = (TextView) findViewById(R.id.tv_description);
        mSelIv = (ImageView) findViewById(R.id.iv_selected_mark);
        mContentLl = (LinearLayout) findViewById(R.id.ll_two_lines_cell);
    }
}
